package com.weimei.conversionTreasure.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.weimei.conversionTreasure.BuildConfig;
import com.weimei.conversionTreasure.R;
import com.weimei.conversionTreasure.databinding.ActivityAboutBinding;
import com.weimei.conversionTreasure.utils.UserUtils;
import com.weimei.conversionTreasure.viewModel.AboutVM;

import me.goldze.mvvmhabit.base.BaseActivity;
import me.goldze.mvvmhabit.utils.ToastUtils;
import me.tatarka.bindingcollectionadapter2.BR;

public class AboutActivity extends BaseActivity<ActivityAboutBinding, AboutVM> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_about;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        binding.tvCode.setText("V"+ BuildConfig.VERSION_NAME);
        if (UserUtils.isLogin()){
            binding.tvUserId.setText(UserUtils.getUserAccount());
        }

        binding.tvUserId.setOnClickListener(view -> {
            //获取剪贴板管理器：
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            // 创建普通字符型ClipData
            ClipData mClipData = ClipData.newPlainText("Label", binding.tvUserId.getText().toString());
            // 将ClipData内容放到系统剪贴板里。
            cm.setPrimaryClip(mClipData);
            ToastUtils.showShort("复制成功");
        });

        binding.tvUser.setOnClickListener(view -> {
            Bundle bundle = new Bundle();
            bundle.putString("flag","YHXY");
            startActivity(WebActivity.class,bundle);
        });

        binding.tvYs.setOnClickListener(view -> {
            Bundle bundle = new Bundle();
            bundle.putString("flag","YSZC");
            startActivity(WebActivity.class,bundle);
        });

        binding.beian.setOnClickListener(view -> {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("https://beian.miit.gov.cn"));
            startActivity(intent);
        });

    }
}